<template>
    <div class="wrapper">
        <swiper :options="swiperOption">
            <swiper-slide v-for="item of swiperList" :key="item.id">
                <img  class="swiper-img" :src="item.url">
            </swiper-slide>
            <div class="swiper-pagination"  slot="pagination"></div>
     </swiper>
    </div>
</template>

<script>
let vm = null;
export default {
  name: "HomeSwiper",
  data: function() {
    return {
      swiperOption: {
        pagination: {
          el: ".swiper-pagination"
        },
        loop: true,
        autoplay: true,
        on: {
          click: function() {
            const realIndex = this.realIndex
            vm.handleClickSlide(this.realIndex);
          }
        }
      },
      swiperList: [
        {
          id: "001",
          url:
            "http://img1.qunarzz.com/piao/fusion/1810/d9/c76768630363e902.jpg_750x200_5c7f4001.jpg"
        },
        {
          id: "002",
          url:
            "http://img1.qunarzz.com/piao/fusion/1811/ff/1bf7d3a4f6591002.jpg_750x200_be24850a.jpg"
        },
        {
          id: "003",
          url:
            "http://img1.qunarzz.com/piao/fusion/1809/c6/2467595fffc3b302.jpg_750x200_cca13d51.jpg"
        },
        {
          id: "004",
          url:
            "http://img1.qunarzz.com/piao/fusion/1805/77/50a97a04c605f502.jpg_750x200_4a5623f0.jpg"
        },
        {
          id: "005",
          url:
            "http://img1.qunarzz.com/piao/fusion/1809/12/856f100069809e02.jpg_750x200_e3485a2b.jpg"
        }
      ]
    };
  },
  created(){
      vm = this
  },
  methods:{
      handleClickSlide(index){
          alert(this.swiperList[index].url);
      }
  }
};
</script>
<style scoped>
.wrapper >>> .swiper-pagination-bullet-active {
  background-color: white;
}
.wrapper >>> .swiper-pagination-bullet {
  background-color: white;
}
.wrapper {
  width: 100%;
  overflow: hidden;
  height: 0;
  padding-bottom: 26.6%;
  background-color: #eee;
}
.swiper-img {
  width: 100%;
}
</style>
